package com.hxkj.controller;

import com.hxkj.domain.po.ContentMapping;
import com.hxkj.service.ContentMappingService;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.platform.common.domain.result.ResultDataStruct;
import com.platform.common.domain.result.ResultMessageStruct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.concurrent.Callable;

/**
 * @ClassName ContentMappingController
 * @Description TODO
 * @Author Mr.zheng
 * @Date 2018/9/9 14:41
 * @Version 1.0
 */
@RestController
@RequestMapping("/contentMapping")
public class ContentMappingController {

    @Autowired
    private ContentMappingService contentMappingService;

    /**
    * @author Mr.zheng
    * @Description getContentMapping 根据站点和分类ID获取映射表对应字段
    **/
    @HystrixCommand
    @RequestMapping(value = "/getContentMappingList", method = RequestMethod.POST,consumes  ="application/json;charset=UTF-8")
    public Callable<ResultDataStruct<List<ContentMapping>>> getContentMappingList(@RequestBody ContentMapping contentMapping) throws Exception{
        return () -> contentMappingService.getContentMappingList(contentMapping);
    }

    /**
    * @author Mr.zheng
    * @Description saveContentMapping 新增映射字段
    **/
    @RequestMapping(value = "/saveContentMapping", method = RequestMethod.POST,consumes  ="application/json;charset=UTF-8")
    public Callable<ResultMessageStruct> saveContentMapping(@RequestBody ContentMapping contentMapping) throws Exception{
        return () -> contentMappingService.saveContentMapping(contentMapping);
    }
}
